#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long n,l,r;
	cin >> n >> l >> r;
	long long maxn = 0;
	long long p = r / n;
	p *= n;
	p -= 1;
	if(p >= l)
	maxn = max(maxn,p%n);
	else
	maxn = max(maxn,r%n);
	cout << maxn;
	return 0;
}
